<template>
    <div>
        <detail-banner :sightName="sightName" :bannerImg="bannerImg" :bannerImgs="gallaryImgs"></detail-banner>
        <detail-header></detail-header>
        <div class="content">
            <detail-list :list="list"></detail-list>
        </div>
    </div>
</template>
<script>
import detailBanner from './components/Banner'
import detailHeader from './components/Header'
import detailList from './components/List'
import axios from 'axios'
export default {
    name: 'Detail',
    components: {
        detailBanner,
        detailHeader,
        detailList
    },
    data () {
        return {
            sightName: '',
            bannerImg: '',
            gallaryImgs: [],
            list: []
            // list: [{
            //     title: '成人票',
            //     children: [{
            //         title: '成人蹦极'
            //     },{
            //         title: '成人跳伞'
            //     }]
            // },{
            //     title: '学生票',
            //     children: [{
            //         title: '学生艺术表演'
            //     },{
            //         title: '学生美术展'
            //     }]
            // },{
            //     title: '儿童票',
            //     children: [{
            //         title: '儿童泳池'
            //     },{
            //         title: '儿童乐园'
            //     }]
            // }]
        }
    },
    //定义一个方法
    methods: {
       getDetailInfo () {
           axios.get('/api/detail.json',{
               params: {
                   id: this.$route.params.id
               }
           }).then(this.handleGetDataSucc)
       },
       //接收数据
       handleGetDataSucc (res) {
           res = res.data
           if(res.ret = res.data) {
               const data = res.data
               this.sightName = data.sightName
               this.bannerImg = data.bannerImg
               this.gallaryImgs = data.gallaryImgs
               this.list = data.categoryList
           }
       }
    },
    //生命周期钩子
    mounted () {
        this.getDetailInfo()
    }
}
</script>
<style lang="stylus" scoped>
  .content{
      height : 50rem
  }
</style>

